#!/usr/bin/env python
import msg
import gzip

msg.show("""
                _                    
    /\         | |                   
   /  \   ___ _| |___   _____  _  __ 
  / /\ \ / __)     \ \ / / _ \| |/ / 
 / /__\ \> _| (| |) ) v ( (_) ) / /  
/________\___)_   _/ > < \___/|__/   
               | |  / ^ \            
               |_| /_/ \_\           
""", 'green', 1)

while True:
	raw_command = raw_input('>')
	
	# Empty
	if raw_command == '':
		msg.show('No Command Given', 'black', 1)
		continue
	
	# Help
	elif raw_command == 'help' or raw_command == 'h':
		import help
		help.show()
		continue
	
	# Exit
	elif raw_command == 'exit' or raw_command == 'ex':
		msg.show('Shutting Down', 'black', 1)
		exit()
	
	command = raw_command.split()[0]
	
	# Lookup
	if command == 'lookup' or command == 'look' or command == 'l':
		import lookup
		if len(raw_command.split()) == 1:
			lookup.incorrectUsage()
			continue
		params = raw_command.split()
		del params[0]
		lookup.run(*params)
	
	# Update
	elif command == 'update' or command == 'up':
		import update
		if len(raw_command.split()) > 1:
			update.run(raw_command.split()[1])
		else:
			update.run()
		continue
	
	# Define
	elif command == 'define' or command == 'def' or command == 'd':
		if len(raw_command) == 1:
			msg.show('Usage: define <table>', 'red', 1)
			continue
		import help
		params = raw_command.split()
		del params[0]
		for param in params:
			help.define(param)
	
	# Map
	elif command == 'map' or command == 'm':
		if len(raw_command.split()) == 1:
			import worldmap
			worldmap.show()
			continue
		else:
			import mapping
			params = raw_command.split()
			del params[0]
			mapping.show(*params)
			continue
	
	# Invalid
	else:
		msg.show('Invalid Command', 'red', 1);

